/**
 * @file usart.c
 * @author TimeChicken (https://gitee.com/Time--Chicken)
 * @brief 串口测试实验程序
 * @version 0.1
 * @date 2021-11-08
 * 
 * @copyright Copyright (c) 2021
 * 
 */
#ifdef USART_C_TEST // keil5 配置编译时请添加此宏的定义
#define USART_NUMBER 1 // 测试串口1，取值(1~3)

#include <stm32f4xx.h>
#include <string.h>
#include <stdio.h>

#include "usart.h"
#include "delay.h"

int main(void)
{
#if USART_NUMBER == 1
	USART1_Config(115200);
	while(1)
	{
		// print function test.
		print_f("'print_f()' function print data.\r\n");
		print_ln("'print_ln()' function print data.");
		
		usart1_send_str("here is usart1 test data.\r\n");
		delay_ms(1000);
	}
#endif
	
#if USART_NUMBER == 2
	// 波特率不能太高 应该 < 115200 ，否则会出现乱码
	USART2_Config(9600);
	while(1)
	{
		usart2_send_str("here is usart2 test data.\r\n");
		delay_ms(1000);
	}
#endif

#if USART_NUMBER == 3
	USART3_Config(115200);
	while(1)
	{
		usart3_send_str("here is usart3 test data.\r\n");
		delay_ms(1000);
	}
#endif

}
#endif /*USART_C_TEST*/
